<?php
/**
* @package YaForms
* @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
* @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
* YaForms! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
* Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
*/

defined( '_VALID_MOS' ) or die( 'Restricted access' );

//загрузка библиотек
function afLoadLib( $libname ) {

      $path = JPATH_BASE.'/administrator/components/com_yaforms/lib/af.lib.'.$libname.'.php';
      if (file_exists( $path )) {
         require ( $path );
      }
		
}
   
//загрузка языка
function afLoadLang() {
   
      global $mosConfig_lang;
      if ( file_exists ( JPATH_BASE.'/components/com_yaforms/language/'.$mosConfig_lang.'.php' ) ) {
         include( JPATH_BASE.'/components/com_yaforms/language/'.$mosConfig_lang.'.php' );
      } else {
         include( JPATH_BASE.'/components/com_yaforms/language/english.php' );
      }

}


function afGetItemid( $id ) {

      global $database;
      $query = "SELECT a.id"
             . "\n FROM #__menu AS a "
             . "\n WHERE a.published = 1"
             . "\n AND a.link = 'index.php?option=com_yaforms&formid=".(int)$id."' "
             . "\n AND a.type = 'url' OR "
             . "\n a.link = 'index.php?option=com_yaforms&formid=".(int)$id."' "
             . "\n AND a.type = 'yaforms_form_link'"
             ;
      $database->setQuery( $query );
      $result = $database->loadResult();

      return $result;

}

   
function showErrRep() {

      require (JPATH_BASE.'/administrator/components/com_yaforms/config.yaforms.php');
      if ($afcfg_allowerr_rep == '1'){
         return error_reporting(E_ALL);
      } else {
         return error_reporting(0);
      }

}


function afFooter() {
    
    $html = '&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://yar-it.com/" target="_blank" title="Разработка и продвижение сайтов. Создать сайт. Ярославль"><font color="#999999" size="1">Разработка сайтов</font></a>';
	return $html;

    
}


function afLoadSectionTitle( $title, $image, $notaflogo=0, $otherimgpath='' ) {

   if ($notaflogo != 0 ){
      $classtitle = 'aftitle2';
   } else {
      $classtitle = 'aftitle';
   }
   
   $afmsg = stripslashes( strval( mosGetParam( $_REQUEST, 'afmsg', '' ) ) );
   $afimg = mosGetParam( $_REQUEST, 'afimg', '' );
   $imgpath = JPATH_SITE.'/administrator/components/com_yaforms/images/';
   $titleimgpath = $imgpath;
   
   if( $otherimgpath ) $titleimgpath = $otherimgpath;

   $afimg = $afimg ? 'success.png' : 'error.png';
   echo '
   <div class="'.$classtitle.'">
     <table class="adminheading">
  <tr>
    <th class="menus"> <span>
           '.$title.'
      </span> </th>
  </tr>
</table>';
      if ( $afmsg && $notaflogo == 0 ){
         echo '<div class="message">'.$afmsg.'</div>';
      }
   echo '
   </div>';

}


function afLoadTitleError( $frontend=0 ) {

   $html = '';
   $afmsg = stripslashes( strval( mosGetParam( $_REQUEST, 'afmsg', '' ) ) );
   $afimg = mosGetParam( $_REQUEST, 'afimg', '' );

   if( $frontend == 0 ){
      $imgpath = JPATH_SITE.'/administrator/components/com_yaforms/images/';
   } else {
      $imgpath = JPATH_SITE.'/components/com_yaforms/images/';
   }
   
   $image = $afimg ? 'success.png' : 'error.png';

   if ( $afmsg ){

      $html .= '<div class="clear"></div>
                  <div class="aferrorm">
                  <img src="'.$imgpath.$image.'">'.' '.$afmsg.'
               </div>
               <div class="clear"></div>';

   }

   return $html;

}


function afPanelButton( $task, $image, $text ) {
     global $mainframe;
     $path  = JPATH_SITE.'/administrator/components/com_yaforms/images/';
     $task  = 'index2.php?option=com_yaforms&amp;task='.$task;
     $image = $image;
     ?>

<span> <a href="<?php echo $task;?>"> <img src="<?php echo $image;?>" alt="<?php echo $text;?>" border="0"> <?php echo $text;?> </a> </span>
<?php
}
// капча
function af_captcha_image(){

		$str = '<div class="yf_field_name"><div class="affieldname">'.YAF_CAPTCHA_TITLE.'</div></div><div class="yf_the_field"><img src="'.JPATH_SITE.'/includes/libraries/kcaptcha/index.php?session=' .mosMainFrame::sessionCookieName(). '" alt="'.YAF_CAPTCHA_TITLE.'" /> <br /><input name="captcha" type="text" class="textinput" size="15" maxlength="15" /></div>';
		
		return $str;
	}
//версия
function afVersionYar() {

   $YaForms_version = '1.1 RC5';
   return $YaForms_version;
   
}

function afCopyImgTmp( $image ) {
   
   copy(JPATH_BASE.'/components/com_yaforms/images/temp/'.$image, JPATH_BASE.'/images/yaforms/asterisks/'.$image);

}


function afDelImgTmp( $image ) {

   unlink(JPATH_BASE.'/components/com_yaforms/images/temp/'.$image);

}

function afDelDirTmp( $dir ) {

   rmdir(JPATH_BASE.'/components/com_yaforms/images/'.$dir.'/');

}
?>
